package com.learn.springcloud.service;

import java.util.List;

import org.springframework.stereotype.Component;

import com.learn.springcloud.entity.Dept;

import feign.hystrix.FallbackFactory;
@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory<DeptClientService>{

	@Override
	public DeptClientService create(Throwable arg0) {
		return new DeptClientService(){

			@Override
			public boolean add(Dept dept) {
				return false;
			}

			@Override
			public Dept get(Long id) {
				Dept dept = new Dept();
				dept.setDeptno(id);
				dept.setDname("该ID:"+id+"没有对应的信息,Consumer客户端提供的降级信息，此刻服务Provider已经关闭，--@HystrixCommand");
				dept.setDb_source("provider is down...");
				return dept;
			}

			@Override
			public List<Dept> list() {
				return null;
			}
			
		};
	}

}
